Fix crash when setting empty playlist on ExoPlayer with ForwardingSim…#2673
Closed
nift4 wants to merge 1 commit intoandroidx:mainfrom
Closed
Fix crash when setting empty playlist on ExoPlayer with ForwardingSim…#2673nift4 wants to merge 1 commit intoandroidx:mainfrom
nift4 wants to merge 1 commit intoandroidx:mainfrom
Conversation
Contributor
Author
|
to reproduce: diff --git a/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt b/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt
index 134405ed9b..a805ab9533 100644
--- a/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt
+++ b/demos/session/src/main/java/androidx/media3/demo/session/PlayerActivity.kt
@@ -203,7 +203,8 @@ class PlayerActivity : AppCompatActivity() {
.setTextColor(ContextCompat.getColor(context, R.color.white))
deleteButton.visibility = View.VISIBLE
deleteButton.setOnClickListener {
- controller.removeMediaItem(position)
+ //controller.removeMediaItem(position)
+ controller.setMediaItems(mutableListOf())
updateCurrentPlaylistUI()
}
}
diff --git a/demos/session_service/src/main/java/androidx/media3/demo/session/DemoPlaybackService.kt b/demos/session_service/src/main/java/androidx/media3/demo/session/DemoPlaybackService.kt
index 66d68fd647..a69b524c0d 100644
--- a/demos/session_service/src/main/java/androidx/media3/demo/session/DemoPlaybackService.kt
+++ b/demos/session_service/src/main/java/androidx/media3/demo/session/DemoPlaybackService.kt
@@ -30,6 +30,7 @@ import androidx.datastore.core.DataStore
import androidx.datastore.core.Serializer
import androidx.datastore.dataStore
import androidx.media3.common.AudioAttributes
+import androidx.media3.common.ForwardingSimpleBasePlayer
import androidx.media3.common.Player
import androidx.media3.common.listen
import androidx.media3.common.util.UnstableApi
@@ -137,10 +138,10 @@ open class DemoPlaybackService : MediaLibraryService() {
@OptIn(UnstableApi::class) // Player.listen
private fun initializeSessionAndPlayer() {
val player =
- ExoPlayer.Builder(this)
+ ForwardingSimpleBasePlayer(ExoPlayer.Builder(this)
.setAudioAttributes(AudioAttributes.DEFAULT, /* handleAudioFocus= */ true)
- .build()
- player.addAnalyticsListener(EventLogger())
+ .build())
+ //player.addAnalyticsListener(EventLogger())
CoroutineScope(Dispatchers.Unconfined).launch {
player.listen { events ->
if ( |
1 task
Collaborator
|
Thanks for reporting! I'll fix it in a slightly different way without merging this PR if that's okay? |
Contributor
Author
|
Sure! Thanks. |
copybara-service bot
pushed a commit
that referenced
this pull request
Jul 30, 2025
Staying in STATE_BUFFERING or STATE_READY is not allowed while the playlist is empty. Issue: #2673 PiperOrigin-RevId: 788929128
nift4
pushed a commit
to nift4/media
that referenced
this pull request
Jul 30, 2025
Staying in STATE_BUFFERING or STATE_READY is not allowed while the playlist is empty. Issue: androidx#2673 PiperOrigin-RevId: 788929128
ghhccghk
pushed a commit
to ghhccghk/media
that referenced
this pull request
Aug 11, 2025
Staying in STATE_BUFFERING or STATE_READY is not allowed while the playlist is empty. Issue: androidx#2673 PiperOrigin-RevId: 788929128
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…pleBasePlayer